/*
============================================================================
 Name        : BasePage.h
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : BasePage.h - header file
============================================================================
*/

#ifndef BASEPAGE_H
#define BASEPAGE_H

#include "LinkList.h"
#include "XString.h"
#include "XCommon.h"
//UIKeyboardType
enum {
    G_UIKeyboardTypeDefault,                // Default type for the current input method.
    G_UIKeyboardTypeASCIICapable,           // Displays a keyboard which can enter ASCII characters.
    G_UIKeyboardTypeNumbersAndPunctuation,  // Numbers and assorted punctuation.
    G_UIKeyboardTypeURL,                    // A type optimized for URL entry (shows . / .com prominently).
    G_UIKeyboardTypeNumberPad,              // A number pad (0-9). Suitable for PIN entry.
    G_UIKeyboardTypePhonePad,               // A phone pad (1-9, *, 0, #, with letters under the numbers).
    G_UIKeyboardTypeNamePhonePad,           // A type optimized for entering a person's name or phone number.
    G_UIKeyboardTypeEmailAddress,           // A type optimized for multiple email address entry (shows space @ . prominently).
	
    G_UIKeyboardTypeAlphabet = G_UIKeyboardTypeASCIICapable, // Deprecated
	
};
//UIReturnKeyType
typedef enum {
    G_UIReturnKeyDefault,
    G_UIReturnKeyGo,
    G_UIReturnKeyGoogle,
    G_UIReturnKeyJoin,
    G_UIReturnKeyNext,
    G_UIReturnKeyRoute,
    G_UIReturnKeySearch,
    G_UIReturnKeySend,
    G_UIReturnKeyYahoo,
    G_UIReturnKeyDone,
    G_UIReturnKeyEmergencyCall,
};

enum {GCON_NON,GCON_EDITOR,GCON_SELECT,GCON_NOTE};
enum {GCON_EVENT_BTN,GCON_EVENT_REMOVE};
#define MAX_SELECT_NUM 5
class CGameControll
{
public:
	CGameControll()
	{
		conType = GCON_NON;
		conId   = 0;
		keyBoardType = G_UIKeyboardTypeDefault;
		returnKeyType = G_UIReturnKeyDone;
		fontName = FONT_A;
		fontSize = 24;
		maxInputNum = 256;
		isPassWord = false;
		isNeedClearBtn = false;
		dataSelectNum = 0;
		isLockTouch = true;
		isAutoCopyResult = true;
		isRemoveCallBack = true;
		isMultiLine = false;
	};
	~CGameControll()
	{
	};
public:
	int16 conType;
	int16 conId;
	_Rect conArea;
	bool isLockTouch;
	int16 callBackEvent;
	bool  isRemoveCallBack;
//////////CONTROLL_EDITOR
	int16 keyBoardType;
	int16 returnKeyType;
	CXString nullTxt;
	CXString fontName;
	int16 fontSize;
	int16 maxInputNum;
	CXString resultTxt;
	bool isPassWord;
	bool isNeedClearBtn;
	bool isAutoCopyResult;
	bool isMultiLine;
//////////GCON_SELECT
	CXList<CXString> dataList[MAX_SELECT_NUM];
	int16 dataSelect[MAX_SELECT_NUM];
	int16 dataSelectNum;
//////////GCON_NOTE
	CXString title;
	CXString message;
	CXString lBtnName;
	CXString rBtnName;
	int16 lBtnId;
	int16 rBtnId;
	int16 btnSelectId;
};

class CXFolder
{
public:
	CXFolder(const char* name,CXFolder *father,int16 type,int16 icon,bool isCanIn);
	CXFolder(const CXString& name,CXFolder *father,int16 type,int16 icon,bool isCanIn);
	virtual ~CXFolder();
	CXFolder * AddNewSub(const char* name,int16 type,int16 icon,bool isCanIn,int16 pos=-1);
	CXFolder * AddNewSub(const CXString& name,int16 type,int16 icon,bool isCanIn,int16 pos=-1);
	CXFolder * AddSubLink(CXFolder *sub,int16 pos=-1);
	void DelSub(int16 index);
	void DelSub(CXFolder *folder);
	void DelAll();
public:
	CXString          m_Name;
	CXString          m_Tips;
	int16             m_Index;
	int16             m_Drawpos;
	int16             m_Type;
	int16             m_Icon;
	bool              m_IsCanIn;
	_Rect             m_Area;
	CXFolder *        m_Father;
	CXList<CXFolder>  m_Subfolder;
};

class CBasePage
{
public:
	CBasePage(){}
	virtual ~CBasePage(){}
	virtual void Create(){}
	virtual void Release(){}
	virtual void Load(){}
	virtual void UnLoad(){}
	virtual void Deal(int timeElapsedMS){}
	virtual void Draw(int32 posX,int32 posY){}
	virtual void MenuCallBack(int16 cmdid){}
	virtual void NoteCallBack(int16 cmdid,int16 key){}
	virtual void ChooseCallBack(int16 cmdid,int16 chooseId){}
	virtual void ControllCallBack(CGameControll * conData){}
	virtual void NetSendDataCall(int16 command,DataStream* stream){}
	virtual void NetRecvDataCall(int16 command,DataStream* stream){}
	virtual void NetDownloadCall(int16 fileType,CXString filepath){}
	virtual void NetErrorCall(int16 msgType,int16 msgId,CXString errmsg){}
public:
	CBasePage * m_PageFrom;
	bool        m_isCreate;
	int16       m_PageId;
	int32       m_ScollIndex;
	int32       m_ContentHeight;
	CXFolder *  m_ContentList;
};

class ScollObj
{
public:
	ScollObj();
	~ScollObj();
	int DealScoll(int basePos,int starPos,int endPos,int maxScoll,int dir,float speed = 1,bool isCenter = false,_Rect * touch = NULL);
private:
	int m_DownPos;
	int m_LastPos;
	int m_ShakeSpeed;
	int m_MoveSpeed;
	int m_DragSpeed;
};

class CPageManager
{
public:
	CPageManager();
	virtual ~CPageManager();

	CBasePage * AddPage(CBasePage *page,int16 pageid);
	CBasePage * GetPage(int16 pageid);
	void DelPage(int16 pageid);
	void DelAllPage();
	void GotoPage(int16 pageid,bool isRelCurPage=true);
	void Back(bool isRelCurPage=true);
	void SwitchFin();
public:
	CXList<CBasePage> m_AllPage;
	CBasePage *m_PageFrom;
	CBasePage *m_PageTo;
	CBasePage *m_CurPage;
	bool m_isSwitching;
	bool m_isRelCurPage;
};

#endif // BASEPAGE_H

// End of File
